import javax.jws.WebService;

@WebService(targetNamespace="http://localhost:63081/uploadDocument")
public class UploadDocumentService {

	public String uploadDocument(String projectID, String docName, String docLink)
	{
		Project p = ProjectContainer.getInstance().getProject(projectID);

		if(p == null)
			return "Project with ID '" + projectID + "' not found";

		boolean exceptionThrown = false;
		try
		{
			p.addFile(docName, docLink);
		}
		catch(Exception e)
		{
			exceptionThrown = true;
		}

		System.out.println("PROJECT IS: " + p);
		System.out.println("PROJECT ID IS: " + projectID);
		System.out.println("PROJECTCONTAINER: " + ProjectContainer.getInstance());
		System.out.println("CONTAINER SIZE: " + ProjectContainer.getInstance().getNoOfProjects());

		if(exceptionThrown)
			return "Document failed to save";
		else
			return "Document successfully saved";
	}
}
